/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.applicatioN.entities;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author Slim
 */
@Entity
@Table(name = "etudier")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Etudier.findAll", query = "SELECT e FROM Etudier e"),
    @NamedQuery(name = "Etudier.findByDateDObtention", query = "SELECT e FROM Etudier e WHERE e.dateDObtention = :dateDObtention"),
    @NamedQuery(name = "Etudier.findByMention", query = "SELECT e FROM Etudier e WHERE e.mention = :mention"),
    @NamedQuery(name = "Etudier.findBySpecialite", query = "SELECT e FROM Etudier e WHERE e.etudierPK.specialite = :specialite"),
    @NamedQuery(name = "Etudier.findByIdentifiant", query = "SELECT e FROM Etudier e WHERE e.etudierPK.identifiant = :identifiant"),
    @NamedQuery(name = "Etudier.findByNom", query = "SELECT e FROM Etudier e WHERE e.etudierPK.nom = :nom")})
public class Etudier implements Serializable {

    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected EtudierPK etudierPK;
    @Basic(optional = false)
    @Column(name = "DATE_D_OBTENTION")
    @Temporal(TemporalType.DATE)
    private Date dateDObtention;
    @Basic(optional = false)
    @Column(name = "MENTION")
    private String mention;
    @JoinColumn(name = "SPECIALITE", referencedColumnName = "SPECIALITE", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Specialite specialite1;
    @JoinColumn(name = "NOM", referencedColumnName = "NOM", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Ecole ecole;
    @JoinColumn(name = "IDENTIFIANT", referencedColumnName = "IDENTIFIANT", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Candidat candidat;

    public Etudier() {
    }

    public Etudier(EtudierPK etudierPK) {
        this.etudierPK = etudierPK;
    }

    public Etudier(EtudierPK etudierPK, Date dateDObtention, String mention) {
        this.etudierPK = etudierPK;
        this.dateDObtention = dateDObtention;
        this.mention = mention;
    }

    public Etudier(String specialite, int identifiant, String nom) {
        this.etudierPK = new EtudierPK(specialite, identifiant, nom);
    }

    public EtudierPK getEtudierPK() {
        return etudierPK;
    }

    public void setEtudierPK(EtudierPK etudierPK) {
        this.etudierPK = etudierPK;
    }

    public Date getDateDObtention() {
        return dateDObtention;
    }

    public Ecole getEcole() {
        return ecole;
    }

    public Specialite getSpecialite() {
        return specialite1;
    }

    public void setDateDObtention(Date dateDObtention) {
        this.dateDObtention = dateDObtention;
    }

    public String getMention() {
        return mention;
    }

    public void setMention(String mention) {
        this.mention = mention;
    }

    public Specialite getSpecialite1() {
        return specialite1;
    }

    public void setSpecialite1(Specialite specialite1) {
        this.specialite1 = specialite1;
    }

    public void setEcole(Ecole ecole) {
        this.ecole = ecole;
    }

    public Candidat getCandidat() {
        return candidat;
    }

    public void setCandidat(Candidat candidat) {
        this.candidat = candidat;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (etudierPK != null ? etudierPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Etudier)) {
            return false;
        }
        Etudier other = (Etudier) object;
        if ((this.etudierPK == null && other.etudierPK != null) || (this.etudierPK != null && !this.etudierPK.equals(other.etudierPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.applicatioN.entities.Etudier[ etudierPK=" + etudierPK + " ]";
    }
}
